package com.loan.web.page;

import com.loan.entity.Product;
import com.loan.exception.ProductException;
import com.loan.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
@Controller
@RequestMapping("/page/product")
public class ProducControllerPage {
    @Autowired
    private ProductService productService;
    /**
     * 查询所有的产品信息
     */
    @RequestMapping("/product_list")
    public String productList(Model model) {
        List<Product> list = productService.list();
        if (list.size() > 0) {
            model.addAttribute("product",list);
            return "product_list";
        }
        throw new ProductException("没有任何产品推荐");
    }
}
